package com.fitns.user.mapper.baseConfig;

import static com.fitns.user.mapper.baseConfig.TbPersonLedgerDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbPersonLedger;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbPersonLedgerMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbPersonLedger> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbPersonLedgerResult")
    TbPersonLedger selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbPersonLedgerResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.VARCHAR),
        @Result(column="id_card", property="idCard", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="organ_id", property="organId", jdbcType=JdbcType.BIGINT),
        @Result(column="attendance_way", property="attendanceWay", jdbcType=JdbcType.VARCHAR),
        @Result(column="sos", property="sos", jdbcType=JdbcType.VARCHAR),
        @Result(column="one_button", property="oneButton", jdbcType=JdbcType.VARCHAR),
        @Result(column="two_button", property="twoButton", jdbcType=JdbcType.VARCHAR),
        @Result(column="three_button", property="threeButton", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_enter", property="isEnter", jdbcType=JdbcType.BIT),
        @Result(column="social_num", property="socialNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="record_num", property="recordNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="contract_num", property="contractNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="guard_time", property="guardTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="leave_time", property="leaveTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="terminal", property="terminal", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column= "image", property= "image", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="modify_id", property="modifyId", jdbcType=JdbcType.BIGINT),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TbPersonLedger> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(tbPersonLedger);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbPersonLedger);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbPersonLedger)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbPersonLedger record) {
        return insert(SqlBuilder.insert(record)
                .into(tbPersonLedger)
                .map(name).toProperty("name")
                .map(sex).toProperty("sex")
                .map(idCard).toProperty("idCard")
                .map(phone).toProperty("phone")
                .map(address).toProperty("address")
                .map(organId).toProperty("organId")
                .map(attendanceWay).toProperty("attendanceWay")
                .map(sos).toProperty("sos")
                .map(oneButton).toProperty("oneButton")
                .map(twoButton).toProperty("twoButton")
                .map(threeButton).toProperty("threeButton")
                .map(isEnter).toProperty("isEnter")
                .map(socialNum).toProperty("socialNum")
                .map(recordNum).toProperty("recordNum")
                .map(contractNum).toProperty("contractNum")
                .map(guardTime).toProperty("guardTime")
                .map(leaveTime).toProperty("leaveTime")
                .map(terminal).toProperty("terminal")
                .map(remark).toProperty("remark")
                .map(image).toProperty("image")
                .map(createId).toProperty("createId")
                .map(modifyId).toProperty("modifyId")
                .map(inputTime).toProperty("inputTime")
                .map(modifyTime).toProperty("modifyTime")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbPersonLedger record) {
        return insert(SqlBuilder.insert(record)
                .into(tbPersonLedger)
                .map(name).toPropertyWhenPresent("name", record::getName)
                .map(sex).toPropertyWhenPresent("sex", record::getSex)
                .map(idCard).toPropertyWhenPresent("idCard", record::getIdCard)
                .map(phone).toPropertyWhenPresent("phone", record::getPhone)
                .map(address).toPropertyWhenPresent("address", record::getAddress)
                .map(organId).toPropertyWhenPresent("organId", record::getOrganId)
                .map(attendanceWay).toPropertyWhenPresent("attendanceWay", record::getAttendanceWay)
                .map(sos).toPropertyWhenPresent("sos", record::getSos)
                .map(oneButton).toPropertyWhenPresent("oneButton", record::getOneButton)
                .map(twoButton).toPropertyWhenPresent("twoButton", record::getTwoButton)
                .map(threeButton).toPropertyWhenPresent("threeButton", record::getThreeButton)
                .map(isEnter).toPropertyWhenPresent("isEnter", record::getIsEnter)
                .map(socialNum).toPropertyWhenPresent("socialNum", record::getSocialNum)
                .map(recordNum).toPropertyWhenPresent("recordNum", record::getRecordNum)
                .map(contractNum).toPropertyWhenPresent("contractNum", record::getContractNum)
                .map(guardTime).toPropertyWhenPresent("guardTime", record::getGuardTime)
                .map(leaveTime).toPropertyWhenPresent("leaveTime", record::getLeaveTime)
                .map(terminal).toPropertyWhenPresent("terminal", record::getTerminal)
                .map(remark).toPropertyWhenPresent("remark", record::getRemark)
                .map(image).toPropertyWhenPresent("image", record::getImage)
                .map(createId).toPropertyWhenPresent("createId", record::getCreateId)
                .map(modifyId).toPropertyWhenPresent("modifyId", record::getModifyId)
                .map(inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(modifyTime).toPropertyWhenPresent("modifyTime", record::getModifyTime)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbPersonLedger>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, id, name, sex, idCard, phone, address, organId, attendanceWay, sos, oneButton, twoButton, threeButton, isEnter, socialNum, recordNum, contractNum, guardTime, leaveTime, terminal, remark, image, createId, modifyId, inputTime, modifyTime)
                .from(tbPersonLedger);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbPersonLedger>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, id, name, sex, idCard, phone, address, organId, attendanceWay, sos, oneButton, twoButton, threeButton, isEnter, socialNum, recordNum, contractNum, guardTime, leaveTime, terminal, remark, image, createId, modifyId, inputTime, modifyTime)
                .from(tbPersonLedger);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbPersonLedger selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, id, name, sex, idCard, phone, address, organId, attendanceWay, sos, oneButton, twoButton, threeButton, isEnter, socialNum, recordNum, contractNum, guardTime, leaveTime, terminal, remark, image, createId, modifyId, inputTime, modifyTime)
                .from(tbPersonLedger)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbPersonLedger record) {
        return UpdateDSL.updateWithMapper(this::update, tbPersonLedger)
                .set(name).equalTo(record::getName)
                .set(sex).equalTo(record::getSex)
                .set(idCard).equalTo(record::getIdCard)
                .set(phone).equalTo(record::getPhone)
                .set(address).equalTo(record::getAddress)
                .set(organId).equalTo(record::getOrganId)
                .set(attendanceWay).equalTo(record::getAttendanceWay)
                .set(sos).equalTo(record::getSos)
                .set(oneButton).equalTo(record::getOneButton)
                .set(twoButton).equalTo(record::getTwoButton)
                .set(threeButton).equalTo(record::getThreeButton)
                .set(isEnter).equalTo(record::getIsEnter)
                .set(socialNum).equalTo(record::getSocialNum)
                .set(recordNum).equalTo(record::getRecordNum)
                .set(contractNum).equalTo(record::getContractNum)
                .set(guardTime).equalTo(record::getGuardTime)
                .set(leaveTime).equalTo(record::getLeaveTime)
                .set(terminal).equalTo(record::getTerminal)
                .set(remark).equalTo(record::getRemark)
                .set(image).equalTo(record::getImage)
                .set(createId).equalTo(record::getCreateId)
                .set(modifyId).equalTo(record::getModifyId)
                .set(inputTime).equalTo(record::getInputTime)
                .set(modifyTime).equalTo(record::getModifyTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbPersonLedger record) {
        return UpdateDSL.updateWithMapper(this::update, tbPersonLedger)
                .set(name).equalToWhenPresent(record::getName)
                .set(sex).equalToWhenPresent(record::getSex)
                .set(idCard).equalToWhenPresent(record::getIdCard)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(address).equalToWhenPresent(record::getAddress)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(attendanceWay).equalToWhenPresent(record::getAttendanceWay)
                .set(sos).equalToWhenPresent(record::getSos)
                .set(oneButton).equalToWhenPresent(record::getOneButton)
                .set(twoButton).equalToWhenPresent(record::getTwoButton)
                .set(threeButton).equalToWhenPresent(record::getThreeButton)
                .set(isEnter).equalToWhenPresent(record::getIsEnter)
                .set(socialNum).equalToWhenPresent(record::getSocialNum)
                .set(recordNum).equalToWhenPresent(record::getRecordNum)
                .set(contractNum).equalToWhenPresent(record::getContractNum)
                .set(guardTime).equalToWhenPresent(record::getGuardTime)
                .set(leaveTime).equalToWhenPresent(record::getLeaveTime)
                .set(terminal).equalToWhenPresent(record::getTerminal)
                .set(remark).equalToWhenPresent(record::getRemark)
                .set(image).equalToWhenPresent(record::getImage)
                .set(createId).equalToWhenPresent(record::getCreateId)
                .set(modifyId).equalToWhenPresent(record::getModifyId)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(modifyTime).equalToWhenPresent(record::getModifyTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbPersonLedger record) {
        return UpdateDSL.updateWithMapper(this::update, tbPersonLedger)
                .set(name).equalTo(record::getName)
                .set(sex).equalTo(record::getSex)
                .set(idCard).equalTo(record::getIdCard)
                .set(phone).equalTo(record::getPhone)
                .set(address).equalTo(record::getAddress)
                .set(organId).equalTo(record::getOrganId)
                .set(attendanceWay).equalTo(record::getAttendanceWay)
                .set(sos).equalTo(record::getSos)
                .set(oneButton).equalTo(record::getOneButton)
                .set(twoButton).equalTo(record::getTwoButton)
                .set(threeButton).equalTo(record::getThreeButton)
                .set(isEnter).equalTo(record::getIsEnter)
                .set(socialNum).equalTo(record::getSocialNum)
                .set(recordNum).equalTo(record::getRecordNum)
                .set(contractNum).equalTo(record::getContractNum)
                .set(guardTime).equalTo(record::getGuardTime)
                .set(leaveTime).equalTo(record::getLeaveTime)
                .set(terminal).equalTo(record::getTerminal)
                .set(remark).equalTo(record::getRemark)
                .set(image).equalTo(record::getImage)
                .set(createId).equalTo(record::getCreateId)
                .set(modifyId).equalTo(record::getModifyId)
                .set(inputTime).equalTo(record::getInputTime)
                .set(modifyTime).equalTo(record::getModifyTime)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbPersonLedger record) {
        return UpdateDSL.updateWithMapper(this::update, tbPersonLedger)
                .set(name).equalToWhenPresent(record::getName)
                .set(sex).equalToWhenPresent(record::getSex)
                .set(idCard).equalToWhenPresent(record::getIdCard)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(address).equalToWhenPresent(record::getAddress)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(attendanceWay).equalToWhenPresent(record::getAttendanceWay)
                .set(sos).equalToWhenPresent(record::getSos)
                .set(oneButton).equalToWhenPresent(record::getOneButton)
                .set(twoButton).equalToWhenPresent(record::getTwoButton)
                .set(threeButton).equalToWhenPresent(record::getThreeButton)
                .set(isEnter).equalToWhenPresent(record::getIsEnter)
                .set(socialNum).equalToWhenPresent(record::getSocialNum)
                .set(recordNum).equalToWhenPresent(record::getRecordNum)
                .set(contractNum).equalToWhenPresent(record::getContractNum)
                .set(guardTime).equalToWhenPresent(record::getGuardTime)
                .set(leaveTime).equalToWhenPresent(record::getLeaveTime)
                .set(terminal).equalToWhenPresent(record::getTerminal)
                .set(remark).equalToWhenPresent(record::getRemark)
                .set(image).equalToWhenPresent(record::getImage)
                .set(createId).equalToWhenPresent(record::getCreateId)
                .set(modifyId).equalToWhenPresent(record::getModifyId)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(modifyTime).equalToWhenPresent(record::getModifyTime)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}